package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/5/17 15:43
 * @since v1.0
 */
@Getter
public enum SetTypeEnum {
    DISABLE_ALL(1,"enum.setType.descript.disable_all"),
    DISABLE_OPEN(2,"enum.setType.descript.disable_open"),
    DISABLE_REPEAT(3,"enum.setType.descript.disable_repeat"),
    DISABLE_NONE(4,"enum.setType.descript.disable_none"),
    ;

    SetTypeEnum(Integer code, String descript) {
        this.code = code;
        this.descript = descript;
    }

    private Integer code;
    private String descript;

    /**
     * 获取描述
     * @param code
     * @return java.lang.String
     * @author zcp
     * @date 2019/6/30 22:25
     * @since v1.0
     * @version v1.0
     */
    public static String getSetTypeDesc(Integer code){
        for (SetTypeEnum cache: values()){
            if(cache.getCode().equals(code)){
                return cache.descript;
            }
        }
        return null;
    }

    public String getDescript() {
        return I18nMessageUtil.getMessage(descript);
    }
}
